# coding: utf-8
from pyspark import SparkConf, SparkContext

if __name__ == '__main__':
    conf=SparkConf().setAppName("HelloWorld")
    sc=SparkContext(conf=conf)
    file_add=sc.textFile("hdfs://master:9000/word.txt")
    words=file_add.flatMap(lambda x: x.split(" "))
    words_one=words.map(lambda word: (word,1))
    res=words_one.reduceByKey(lambda a,b: a+b)
    print(res.collect())
